//using built in function (last) to find the last element of a list 
def last_ele_b[A](l: List[A]): A = l.last


//writing same program with recursion, pattern matching
 def last_ele_r[A](l: List[A]): A = l match {
    case start :: Nil  => start
    case _ :: end => last_ele_r(end)
    case _         => throw new NoSuchElementException
  }
}
//The wildcard pattern (_) also
//matches every value, but it does not introduce a variable name to refer to that
//value.